#!/bin/bash

export RED="\e[31m"
export GREEN="\e[32m"
export YELLOW="\e[33m"
export GRAY="\e[37m"
export ENDCOLOR="\e[0m"

if [ "$(os::is_macos)" = "true" ]; then
  RED="\033[31m"
  GREEN="\033[32m"
  YELLOW="\033[33m"
  GRAY="\033[37m"
  ENDCOLOR="\033[0m"
fi

color::success() {
  if [ "$(os::is_support_color)" = "false" ]; then
    echo $@
    return
  fi

  echo -e "${GREEN}${@}${ENDCOLOR}"
}

color::error() {
  if [ "$(os::is_support_color)" = "false" ]; then
    echo $@
    return
  fi

  echo -e "${RED}${@}${ENDCOLOR}"
}

color::warn() {
  if [ "$(os::is_support_color)" = "false" ]; then
    echo $@
    return
  fi

  echo -e "${YELLOW}${@}${ENDCOLOR}"
}

color::disable() {
  if [ "$(os::is_support_color)" = "false" ]; then
    echo $@
    return
  fi

  echo -e "${GRAY}${@}${ENDCOLOR}"
}

color::green() {
  if [ "$(os::is_support_color)" = "false" ]; then
    echo $@
    return
  fi

  echo -e "${GREEN}${@}${ENDCOLOR}"
}

color::red() {
  if [ "$(os::is_support_color)" = "false" ]; then
    echo $@
    return
  fi

  echo -e "${RED}${@}${ENDCOLOR}"
}

color::yellow() {
  if [ "$(os::is_support_color)" = "false" ]; then
    echo $@
    return
  fi

  echo -e "${YELLOW}${@}${ENDCOLOR}"
}

export -f color::success
export -f color::error
export -f color::warn
export -f color::disable

export -f color::green
export -f color::red
export -f color::yellow
